package com.memo.controller;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.memo.R;
import com.memo.model.ListItemPickDay;

public class PickDayListAdapter extends ArrayAdapter<ListItemPickDay>{
	private Activity mContext;
	private ListItemPickDay[] mListItem;
    
	public PickDayListAdapter(Context context, ListItemPickDay[] listItemSimple) {
        super(context, R.layout.list_row_pick_day);
        this.mContext = (Activity) context;
        this.mListItem = listItemSimple;
    }
	
	@Override
	public int getCount() {
		return mListItem.length;
	}

	@Override
	public ListItemPickDay getItem(int position) {
		return mListItem[position];
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View row;
        row = inflater.inflate(R.layout.list_row_pick_day, null);

        TextView tvName = (TextView) row.findViewById(R.id.list_row_pick_name);
        tvName.setText(mListItem[position].getName());
        
        TextView tvDate = (TextView) row.findViewById(R.id.list_row_pick_date);
        tvDate.setText(mListItem[position].getDate().toString());
        
        ImageView ic_edit = (ImageView) row.findViewById(R.id.list_row_pick_edit);
        ic_edit.setImageResource(R.drawable.icon);

        return row;
	}

}
